<?php
/*
Autor: Marek Křivan
(c) 2009 
*/
if(intval($_SESSION['rank']) < 2){
	exit(WRONG_PERMISSIONS);
}

ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);

$id_edit = 1 * $q[4];
$id_tematu = 1 * $q[2];
if((isset($_POST['editovat']))) {
                $edit_titulek = orez_retezec_2($_POST['zprava']);
                $query = $GLOBALS['db']->query("UPDATE " . $GLOBALS['db_prefix'] ."forum_prispevky SET zprava = '$edit_titulek' WHERE id = '$id_edit';");
                $seo = ($GLOBALS['seo']) ? '' : 'index.php?q=';
                echo "<meta http-equiv=\"refresh\" content=\"1;".$GLOBALS['url']. $seo ."forum/dues/".$id_tematu."/".$q[3]."\" />";
        } else
        if($q['1'] == "edit_tema") {
                $query = $GLOBALS['db']->query("SELECT zprava FROM " . $GLOBALS['db_prefix'] ."forum_prispevky WHERE id = '$id_edit';");
               $edit = $query->fetch_array();
                echo "<form action=\"".$GLOBALS['url']."index.php?q=forum/edit_tema/".$id_tematu."/".$q[3]."/".$q[4]."\" method=\"post\">
                <fieldset>
                        <legend>Editovat zprávu</legend>";

                echo "\t\t\t<label>Zpráva: </label><textarea name=\"zprava\" cols=\"47\" rows=\"7\" id=\"txt\">".$edit['zprava']."</textarea>";


                echo "\t\t\t<br /><input type=\"submit\" name=\"editovat\" value=\"Editovat\" id=\"odeslat\" /><br />
                </fieldset>
        </form>";
        }
        

?>